#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, n;
  cin >> x >> n;
  int a, b;
  a = 8 - x;
  b = (n - a) % 7;
  int ans = 0;
  if (a > 2) {
    ans += (a - 2) * 250;
  }
  n -= a;
  ans += (n / 7) * 5 * 250;
  n %= 7;
  if (n > 5) n = 5;
  ans += n * 250;
  cout << ans << endl;
}
